fn main() {
    let s=String::from("hello world");
    let s1=&s[0..5];
    let s2=&s[6..11];
    let s3=&s[0..=4];
    let s4=&s[6..=10];
    println!("s1,s2,s3,s4->{},{},{},{}",s1,s2,s3,s4);

    let mut s = String::from("α is alpha, β is beta");
    let beta_offset = s.find('β').unwrap_or(s.len());
    // Remove the range up until the β from the string
    let t: String = s.drain(..beta_offset).collect();
    println!("t:{},s:{}",t,s);
    assert_eq!(t, "α is alpha, ");
    assert_eq!(s, "β is beta");
    // A full range clears the string
    s.drain(..);
    assert_eq!(s, "");

    let mut s = String::from("α is alpha, β is beta");
    let beta_offset = s.find('β').unwrap_or(s.len());
    // Replace the range up until the β from the string
    s.replace_range(..beta_offset, "Α is capital alpha; ");
    println!("s:{}",s);
    assert_eq!(s, "Α is capital alpha; β is beta");

    let len = "foo".len();
    assert_eq!(3, len);
    let len = "ƒoo".len(); // fancy f!
    assert_eq!(4, len);
    let mut l="哈哈哈".len();
    println!("哈哈哈的长度是：{}",l);
    l="哈哈哈123ABC".len();
    println!("哈哈哈123ABC的长度是：{}",l);

    println!("{}","11foo1bar11".trim_matches('1'));
    println!("{}","123foo1bar123".trim_matches(char::is_numeric));
    println!("{}","foo1bar".trim_matches(char::is_numeric));
    let x: &[_] = &['1', '2'];
    println!("{}","12foo1bar12".trim_matches(x));

    for c in "❤\n!".escape_debug() {
        print!("{}", c);
    }
    println!();
    for c in "❤\n!".escape_debug() {
        println!("{}", c);
    }
    println!("{}", "❤\n!".escape_debug());
    
    println!("❤\\n!");
    for c in "好好学习，天天向上".escape_debug() {
        print!("{}", c);
    }
    for c in "好好学习，天天向上".escape_debug() {
        println!("{}", c);
    }
    println!();

    let s = "this is old";
    println!("s:{},s.rep:{}",s, s.replace("cookie monster", "little lamb"));
}